<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>传统注册</button>
    <button>方法监听注册</button>
    <script>
        var btns = document.querySelectorAll('button');
        // 传统注册具有唯一性
        btns[0].onclick = function() {
            alert('hello');
        }
        // 把上面覆盖掉
        btns[0].onclick = function() {
            alert('hi')
        }
        
        // 方法监听注册事件,不会覆盖
        btns[1].addEventListener('click', function() {
            alert(2);
        })
        btns[1].addEventListener('click', function() {
            alert(3);
        })
        // ie特有btns[2].attachEvent()
        
    </script>
</body>
</html>